<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript" src="js/plugin/upload/ajaxupload.js"></script>
<div class="button_area">
	
	<a  id="upload_button" class="button">导入检查</a>
	
	<a href="order/download" class="button">模板下载</a>
	
</div>
<div id="upload"></div>
<div class="filter_area">
	<s:form>
		<tr>
			<td>

				<table id="search_table" width="100%">
					<thead>
						<tr>
							<td width="200px">
								企业名称
							</td>
					   <!-- REMOVE AT 2012-04-11, FOR REQUIEMENT CHANGE
					   		<td width="100px">
								客户职位
							</td>
							<td width="100px">
								客户姓名
							</td>
							<td width="100px">
								签单类型
							</td>  -->
							<td width="100px">
								<a href="javascript:void(0)" id="add_button">添加</a>
								<a href="javascript:void(0)" id="search_button">搜索</a>
							</td>
						</tr>
					</thead>
					<tbody>

						

					</tbody>
				</table>

			</td>

		</tr>

	</s:form>
</div>
<br>
<table id="order_list" width="100%" border="0" cellspacing="0"cellpadding="0"></table>
<div id="order_pager"></div>


<script type="text/javascript">
$(document).ready(function(){


	
	new Ajax_upload('upload_button', {
		action: 'order/upload',
		name: 'fileData',
		responseType:'json',
		onSubmit : function(file , ext){
			this.setData({fileExt:ext});
			$('#upload').text('上传中 ' + file);
			
		},
		onComplete : function(file,response){
			$('#upload').text('上传完成 ' + file);
			$("#order_list").jqGrid('setGridParam',
						{
							url : "order/check",
							postData: "fileName="+response
						});
			$("#order_list").jqGrid().trigger("reloadGrid");			
		}		
	});		
	
	
	$('#search_button').click(function(){
			$("#order_list").jqGrid('setGridParam',
						{
							url : "order/check",
							postData: $('form').serialize()
						});
			$("#order_list").jqGrid().trigger("reloadGrid");
	});
	$('#add_button').click(function(){
			var buffer=new StringBuffer();
			buffer.append('<tr>');
			buffer.append('<td>');
			buffer.append('<input type="text" name="filters.companyName" style="width: 200px"/>');
			buffer.append('</td>');
//REMOVE AT 2012-04-11, FOR REQUIEMENT CHANGE
//			buffer.append('<td>');
//			buffer.append('<select name="filters.position">');
//			<s:iterator value="positions" status="status">
//				buffer.append('<option value="<s:property value="dictionaryName"/>"><s:property value="dictionaryName"/></option>');
//			</s:iterator>
//			buffer.append('<select>');
//			buffer.append('</td>');
//			buffer.append('<td>');
//			buffer.append('<input type="text" name="filters.customerName"  />');
//			buffer.append('</td>');
//			buffer.append('<td>');
//			buffer.append('<select name="filters.projectType">');
//			<s:iterator value="projectTypes" status="status">
//				buffer.append('<option value="<s:property value="dictionaryName"/>"><s:property value="dictionaryName"/></option>');
//			</s:iterator>
//			buffer.append('<select>');
//			buffer.append('</td>');
			buffer.append('<td>');
			buffer.append('<a href="javascript:void(0)" onclick=$("#order_list").jqGrid("deleteFilterItem",this)>删除</a>');
			buffer.append('</td>');
			buffer.append('</tr>');
			$('#search_table>tbody').append(buffer.toString());
			return false;
	});
	$.jgrid.extend({
		deleteFilterItem:function(atag){
			return this.each(function(){
				var tr=$(atag).parent().parent();
				$(tr).remove();
			});
		}
	});
	$("#order_list").jqGrid({
		url : 'order/check',
		datatype : 'json',
		postData: $('form').serialize(),
		rownumbers: true,
		rowNum:0,
		colModel : [ {
			label : '企业名称',
			name : 'companyName',
			index : 'companyName',
			required : true,
			width : 100,
			editable : false
		}, 
//		{
//			label : '客户职位',
//			name : 'position',
//			index : 'position',
//			required : true,
//			width : 100,
//			editable : false
//		},{label : '客户姓名',
//			name : 'customerName',
//			index : 'customerName',
//			required : true,
//			width : 100,
//			editable : false
//		},{
//			label : '项目类型',
//			name : 'projectType',
//			index : 'projectType',
//			required : true,
//			width : 100,
//			editable : false
//		},
		{
			label : '可用状态',
			name : 'status',
			index : 'statuts',
			required : true,
			width : 100,
			editable : false
		}  ],
		imgpath : '../theme/images/jqgrid/',
		pager : "#order_pager",
		multiselect : false,
		mtype:'post',
		sortname : 'companyName',
		viewrecords : true,
		sortorder : "desc",
		jsonReader : {
			root : "dataRows",
			repeatitems : false
		},
		width : $(document).width() - 80,
		height : $(document).height() - 160
		

	});
	
	
	
});
	

</script>


